From 58192bc9177e81cda7ec6f885da10b5f8e908072 Mon Sep 17 00:00:00 2001 From: PiRSquared17 Date: Wed, 19 Nov 2014 00:01:11 +0000 Subject: [PATCH] Implement namespace inversion on WhatLinksHere This is basically the same as Ie3f72d97e2ba did for SpecialNewPages. Bug: T18848 Change-Id: Id6cbdaca50c81129352962996dc5360f64026ed1 --- includes/specials/SpecialWhatlinkshere.php | 25 ++++++++++++++++------ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index e373cfffb6..07ea93375d 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -58,6 +58,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $opts->add( 'hidetrans', false ); $opts->add( 'hidelinks', false ); $opts->add( 'hideimages', false ); + $opts->add( 'invert', false ); $opts->fetchValuesFromRequest( $this->getRequest() ); $opts->validateIntBounds( 'limit', 0, 5000 ); @@ -125,15 +126,17 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $useLinkNamespaceDBFields = $this->getConfig()->get( 'UseLinkNamespaceDBFields' ); $namespace = $this->opts->getValue( 'namespace' ); + $invert = $this->opts->getValue( 'invert' ); + $nsComparison = ( $invert ? '!= ' : '= ' ) . $dbr->addQuotes( $namespace ); if ( is_int( $namespace ) ) { if ( $useLinkNamespaceDBFields ) { - $conds['pagelinks']['pl_from_namespace'] = $namespace; - $conds['templatelinks']['tl_from_namespace'] = $namespace; - $conds['imagelinks']['il_from_namespace'] = $namespace; + $conds['pagelinks'][] = "pl_from_namespace $nsComparison"; + $conds['templatelinks'][] = "tl_from_namespace $nsComparison"; + $conds['imagelinks'][] = "il_from_namespace $nsComparison"; } else { - $conds['pagelinks']['page_namespace'] = $namespace; - $conds['templatelinks']['page_namespace'] = $namespace; - $conds['imagelinks']['page_namespace'] = $namespace; + $conds['pagelinks'][] = "page_namespace $nsComparison"; + $conds['templatelinks'][] = "page_namespace $nsComparison"; + $conds['imagelinks'][] = "page_namespace $nsComparison"; } } @@ -419,6 +422,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $target = $this->target ? $this->target->getPrefixedText() : ''; $namespace = $this->opts->consumeValue( 'namespace' ); + $nsinvert = $this->opts->consumeValue( 'invert' ); # Build up the form $f = Xml::openElement( 'form', array( 'action' => wfScript() ) ); @@ -450,6 +454,15 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { ) ); + $f .= ' ' . + Xml::checkLabel( + $this->msg( 'invert' )->text(), + 'invert', + 'nsinvert', + $nsinvert, + array( 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() ) + ); + $f .= ' '; # Submit diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 45c7105f24..1c40f75bca 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1993,6 +1993,7 @@ "namespace": "Namespace:", "invert": "Invert selection", "tooltip-invert": "Check this box to hide changes to pages within the selected namespace (and the associated namespace if checked)", + "tooltip-whatlinkshere-invert": "Check this box to hide links from pages within the selected namespace.", "namespace_association": "Associated namespace", "tooltip-namespace_association": "Check this box to also include the talk or subject namespace associated with the selected namespace", "blanknamespace": "(Main)", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 9b090789a9..2b29b5fd31 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2157,6 +2157,7 @@ "namespace": "This message is located at [[Special:Contributions]].\n{{Identical|Namespace}}", "invert": "Displayed in [[Special:RecentChanges|RecentChanges]], [[Special:RecentChangesLinked|RecentChangesLinked]] and [[Special:Watchlist|Watchlist]].\n\nThis message means \"Invert selection of namespace\".\n\nThis message has a tooltip {{msg-mw|tooltip-invert}}\n{{Identical|Invert selection}}", "tooltip-invert": "Used in [[Special:Recentchanges]] as a tooltip for the invert checkbox. See also the message {{msg-mw|invert}}", + "tooltip-whatlinkshere-invert": "Used in [[Special:Whatlinkshere]] as a tooltip for the invert checkbox.\n\nSee also:\n* {{msg-mw|tooltip-invert}}\n* {{msg-mw|invert}}", "namespace_association": "Used in [[Special:Recentchanges]] with a checkbox which selects the associated namespace to be added to the selected namespace, so that both are searched (or excluded depending on another checkbox selection). The association is between a namespace and its talk namespace.\n\nThis message has a tooltip {{msg-mw|tooltip-namespace association}}", "tooltip-namespace_association": "Used in [[Special:Recentchanges]] as a tooltip for the associated namespace checkbox.\n\nSee also:\n* {{msg-mw|Namespace association}}", "blanknamespace": "Name for main namespace (blank namespace) in drop-down menus at [[Special:RecentChanges]] and other special pages.\n{{Identical|Main}}", -- 2.20.1